const { Pool } = require('pg');
require('dotenv').config();

// 构建连接字符串
const connectionString = `postgres://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`;

// 使用连接字符串创建连接池
const pool = new Pool({
  connectionString,
  ssl: false
});

module.exports = {
  query: (text, params) => pool.query(text, params),
}; 